import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ElevatorForm, ElevatorQuery, ElevatorVO } from '@/api/iot/elevator/types';
import { OssVO } from '@/api/system/oss/types';

/**
 * 查询电梯管理列表
 * @param query
 * @returns {*}
 */

export const listElevator = (query?: ElevatorQuery): AxiosPromise<ElevatorVO[]> => {
  return request({
    url: '/iot/elevator/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询电梯管理详细
 * @param elevatorId
 */
export const getElevator = (elevatorId: string | number): AxiosPromise<ElevatorVO> => {
  return request({
    url: '/iot/elevator/' + elevatorId,
    method: 'get'
  });
};

/**
 * 新增电梯管理
 * @param data
 */
export const addElevator = (data: ElevatorForm) => {
  return request({
    url: '/iot/elevator',
    method: 'post',
    data: data
  });
};

/**
 * 修改电梯管理
 * @param data
 */
export const updateElevator = (data: ElevatorForm) => {
  return request({
    url: '/iot/elevator',
    method: 'put',
    data: data
  });
};

/**
 * 删除电梯管理
 * @param elevatorId
 */
export const delElevator = (elevatorId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/elevator/' + elevatorId,
    method: 'delete'
  });
};
/**
 * 查询已分配oss列表
 */
export const allocatedOssList = (query: ElevatorQuery): AxiosPromise<OssVO[]> => {
  return request({
    url: '/iot/elevator/oss/allocatedList',
    method: 'get',
    params: query
  });
};

/**
 * 查询未分配oss列表
 */
export const unallocatedOssList = (query: ElevatorQuery): AxiosPromise<OssVO[]> => {
  return request({
    url: '/iot/elevator/oss/unallocatedList',
    method: 'get',
    params: query
  });
};

/**
 * 取消分配oss
 */
export const ossCancel = (data: any) => {
  return request({
    url: '/iot/elevator/oss/cancel',
    method: 'put',
    data: data
  });
};

/**
 * 批量取消分配oss
 */
export const authOssCancelAll = (data: any) => {
  return request({
    url: '/iot/elevator/oss/cancelAll',
    method: 'put',
    params: data
  });
};

/**
 * 批量分配oss
 */
export const ossSelectAll = (data: any) => {
  return request({
    url: '/iot/elevator/oss/assignAll',
    method: 'put',
    params: data
  });
};
/**
 * 刷新电梯界面
 */
export const refreshElevator = (elevatorId: string | number) => {
  return request({
    url: '/iot/elevator/refresh/' + elevatorId,
    method: 'get'
  });
};

/**
 * 开启板端模型检测
 * @param query
 */
export const modelDetectionEnabled = (query: any) => {
  return request({
    url: '/iot/elevator/modelDetectionEnabled',
    params: query,
    method: 'get'
  });
};
